﻿Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        With FolderBrowserDialog1
            .SelectedPath = "C:\"
            If .ShowDialog() = Windows.Forms.DialogResult.OK Then
                ' You only want to show the file name. The OpenFileDialog.FileName
                ' property contains the full path. So Split the path and reverse it
                ' to grab the first string in the array, which is just the FileName.
                'Dim strFileName() As String = .Container  '  .SelectedPath.Split(New Char() {CChar("\")})
                'System.Array.Reverse(strFileName)
                TextBox1.Text = .SelectedPath  'strFileName(0)
            End If
        End With
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        With OpenFileDialog1
            .InitialDirectory = "C:\"
            .Filter = "Archivos de carga (*.txt)|*.txt|Todos los archivos (*.*)|*.*"
            .FilterIndex = 1
            ' The OpenFileDialog control only has an Open button, not an OK button.
            ' However, there is no DialogResult.Open enum so use DialogResult.OK.
            If .ShowDialog() = Windows.Forms.DialogResult.OK Then TextBox2.Text = .SafeFileName
        End With
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub
End Class